package org.justframework.core;


/**
 * Resource service
 */
public class ResourceService {
	
	/**
	 * semantics 'add'
	 * @param uri
	 * @param params
	 * @return
	 */
	public static Response post(Request request){
		request.setRequestMethod(RequestMethod.POST);
		ClientConnector clientConnector = ClientConnectorFactory.getClientConnector(request.getUri());
		return clientConnector.rpc(request);		
	}
	
	/**
	 * semantics 'delete'
	 * @param uri
	 * @param params
	 * @return
	 */
	public static Response delete(Request request){
		request.setRequestMethod(RequestMethod.DELETE);
		ClientConnector clientConnector = ClientConnectorFactory.getClientConnector(request.getUri());
		return clientConnector.rpc(request);		
	}
	
	/**
	 * semantics 'query'
	 * @param uri
	 * @param params
	 * @return
	 */
	public static Response get(Request request){
		request.setRequestMethod(RequestMethod.GET);
		ClientConnector clientConnector = ClientConnectorFactory.getClientConnector(request.getUri());
		return clientConnector.rpc(request);
	}
	
	/**
	 * semantics 'update'
	 * @param uri
	 * @param params
	 * @return
	 */
	public static Response put(Request request){
		request.setRequestMethod(RequestMethod.PUT);
		ClientConnector clientConnector = ClientConnectorFactory.getClientConnector(request.getUri());
		return clientConnector.rpc(request);		
	}

}